package com.yzd.learnjava.io;

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

import com.yzd.learnjava.util.Print;

public class PreferencesDemo {
	public static void main(String[] args) throws Exception {
		Preferences pre = Preferences.userNodeForPackage(PreferencesDemo.class);
		pre.put("Location", "Oz");
		pre.put("Footewar", "Ruby Slippers");
		pre.putInt("Companions", 4);
		pre.putBoolean("Are there witches", true);
		int usageCount = pre.getInt("UsageCount", 0);
		usageCount++;
		pre.putInt("UsageCount", usageCount);
		for(String key : pre.keys()) {
			Print.print(key + " : " + pre.get(key, null));
		}
		
		Print.print("How many companions does Dornthy have? " + pre.getInt("Companions", 0));
		
	}
}
